// pages/record/record.js
Page({
  data: {
    next: true,
    isRecording: false,
    recordComplete: false,
    interested: ['XXXX', 'XXXX', 'XXXX'],
    editInterest: true,
    interestVal: ''
  },
  onReady: function () {
    this.animation = wx.createAnimation({
      duration: 1000
    });
    this.animation1 = wx.createAnimation({
      duration: 1000
    });
  },
  bindRecordStart: function(e) {
    this.setData({
      isRecording: true
    });
    wx.startRecord({
      success(res) {
        const tempFilePath = res.tempFilePath
        console.log(tempFilePath);
      }
    });
  },
  bindRecordEnd: function(e) {
    var that = this, isRecording = this.data.isRecording;
    if (!isRecording) return;
    this.setData({
      isRecording: false
    });
    wx.stopRecord();
    setTimeout(function(){
      that.setData({
        recordComplete: true
      });
    },500);
  },
  bindRerecord: function(e) {
    this.setData({
      interestVal: '',
      editInterest: false
    });
  },
  gotoNext: function(e) {
    this.animation.opacity(0).step();
    this.animation1.opacity(1).step();
    this.setData({
      animation: this.animation.export(),
      animation1: this.animation1.export(),
      next: false
    })
  },
  startAnswer: function(e) {
    wx.navigateTo({
      url: '../answer/answer',
    })
  }
})